import React from 'react';
import ReactDOM from 'react-dom';

import { HashRouter as Router, Route, Switch, Redirect } from 'react-router-dom'

import { Provider } from 'mobx-react';

import { Tools, Toast, Bubble } from 'weaver-mobile';

import { FloatingTouch } from 'weaver-mobile-page';

import allStore from './stores';

import { asyncComponent } from 'react-async-component';

import './style';

import base from './util/base';

base.init(allStore);

require("./mobileInterface");

const coms = {
    Home: asyncComponent({
        resolve: () => import("./components/Home")
    }),
    Req: asyncComponent({
        resolve: () => import("./components/Req")
    }),
}

class Root extends React.Component {
    render() {
        return (
            <Provider {...allStore}>
                <Router>
                <FloatingTouch onClick={() => this.onHomePageClick()}>
                    <Route name="home" path="/" render={() => {
                        return (
                            <coms.Home>
                                <Route name="req" path="/req" component={coms.Req} />
                            </coms.Home>
                        )
                    }} />
                </FloatingTouch>
                </Router>
            </Provider>
        )
    }
    onHomePageClick() {
        window.location.href = '/#/';
    }
}

Tools.getLocaleLabel("workflow,workflowForm", () => { // 多语言
    ReactDOM.render(<Root />, document.getElementById('root'));
});


window.React = React;
